package homework;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class SortDriver {
    public static void main(String[] args) throws IllegalArgumentException, IOException, ClassNotFoundException, InterruptedException {
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf);
        job.setJarByClass(SortMapper.class);
        job.setJobName("mysort");
        job.setMapperClass(SortMapper.class);
        job.setReducerClass(SortReducer.class);

        job.setOutputKeyClass(LongWritable.class);
        job.setOutputValueClass(LongWritable.class);
        //3个txt文件，结果输出到outsort
        //写入输入输出路径,也可手动传参
        FileInputFormat.addInputPath(job, new Path("C:\\Users\\Administrator\\Desktop\\homework-hadoop1"));
        FileOutputFormat.setOutputPath(job, new Path("D:\\outsort"));
        System.exit(job.waitForCompletion(true) ? 0 : 1);
    }
}
